package com.lk.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ProgressBar;

import com.lk.adapter.MenuListAdapter;
import com.lk.model.ThemeMainInfo;
import com.lk.presenter.MenuListPresenter;
import com.lk.view.IMenuListView;

import java.util.List;

/**
 * Created by liu kun on 2018/8/1 0001.
 */

public class MVPActivity extends Activity implements IMenuListView{
    private RecyclerView menuRv;
    private ProgressBar mPb;
    private MenuListPresenter menuPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mvp_layout);
        initView();
        menuPresenter=new MenuListPresenter(MVPActivity.this);
        menuPresenter.requestData();
    }

    private void initView() {
        menuRv = (RecyclerView) findViewById(R.id.menuRv);
        GridLayoutManager manager=new GridLayoutManager(MVPActivity.this,4);
        menuRv.setLayoutManager(manager);
        mPb= (ProgressBar) findViewById(R.id.mPb);
    }

    @Override
    public void loadData(List<ThemeMainInfo> menuLists) {
        menuRv.setAdapter(new MenuListAdapter(menuLists,MVPActivity.this));
    }

    @Override
    public void showLoading() {
        mPb.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideLoading() {
        mPb.setVisibility(View.GONE);
    }
}
